package com.example.crmweb.controller;


import com.example.crmweb.entity.Role;
import com.example.crmweb.service.impl.RoleAuthServiceImpl;
import com.example.crmweb.lang.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author -CRM-
 * @since 2022-03-18
 */
@RestController
@RequestMapping("/role-auth")
public class RoleAuthController {


    @Resource
    private RoleAuthServiceImpl roleAuthService;

    /**
     * 查询某个角色的所有权限
     * @param id
     * @return
     */
    @GetMapping("/batchGet/{roleId}")
    public Result authByRoleId(@PathVariable("roleId") Integer id){
        return roleAuthService.batchDescribe(id);
    }

    /**
     * 更改某个角色的权限
     * @return
     */
    @PostMapping("/move/{authIds}")
    public Result modifyAuth(Role role,@PathVariable("authIds") Integer[] authIds){
        return roleAuthService.modifyAuth(role,authIds);
    }

}
